package com.cloudsigns.factorymanager2.engineering.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.cloudsigns.factorymanager2.LoginActivity;
import com.cloudsigns.factorymanager2.MyApplicaton;
import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.cusenum.CommonEnum;
import com.cloudsigns.factorymanager2.engineering.bean.AccountInfoBean;
import com.cloudsigns.factorymanager2.engineering.fragment.BaseFragmentActivity;
import com.cloudsigns.factorymanager2.engineering.fragment.MapForManagerFragment;
import com.cloudsigns.factorymanager2.engineering.fragment.EngineeringOrderManagementForManageFragment;
import com.cloudsigns.factorymanager2.produce.activity.AvatarImageShowerActivity;
import com.cloudsigns.factorymanager2.project.activity.EngineeringInstallationScheduleTableActivity;
import com.cloudsigns.factorymanager2.project.activity.ProductStatusTableActivity;
import com.cloudsigns.factorymanager2.project.activity.ProductionScheduleActivity;
import com.cloudsigns.factorymanager2.project.adapter.ProjectMainViewPageAdapter;
import com.cloudsigns.factorymanager2.project.customview.CustomViewPager;

import com.cloudsigns.factorymanager2.project.customview.DropDownPoupWindow;
import com.cloudsigns.factorymanager2.project.customview.GlideCircleTransform;
import com.cloudsigns.factorymanager2.project.customview.PageIndicatorView;
import com.cloudsigns.factorymanager2.project.fragment.InternalOfficeFragment;

import com.cloudsigns.factorymanager2.project.fragment.SettingFragmet;
import com.cloudsigns.factorymanager2.project.utils.ConstantUtil;

import java.util.ArrayList;

/**
 * 工程入口 主页
 * Created by tony on 2018/1/13.
 */

public class EngineeringMainForManagerActivity extends BaseFragmentActivity implements View.OnClickListener {
    private View ll_op_one, ll_op_two, ll_op_three, ll_op_four;
    private ImageView img_op_one, img_op_two, img_op_three, img_op_four;
    private ImageView img_tri_one, img_tri_two, img_tri_three, img_tri_four;
    private ImageView iv_tab_manager, iv_tab_order, iv_tab_office, iv_tab_systems;
    private TextView textview_project_manager,tv_project_order,textview_call,tv_project_systems;
    private RelativeLayout rl_back;
    private View rl_head;
    private TextView tv_title;
    private TextView tv_headtop, tv_headbottom;
    private ImageView img_head;
    private CustomViewPager viewpager;
    private ArrayList<Fragment> listFragments;
    private ProjectMainViewPageAdapter adapter;
    private RelativeLayout layout_engineering_manager, layout_engineering_order, layout_engineering_office, layout_engineering_systems;
    private LinearLayout ll_tab_bottom;
    private Fragment workSheetListFragment, internalOffficeFragemnt, systemFragment;
    private MapForManagerFragment mapForManagerFragment;
    private PageIndicatorView indicator;
    /*四个tab选项*/
    /*工程*/
    public static final int PROJECT_MANAGENT = 0;
    /*工单*/
    public static final int WORK_SHEETS_LIST = 1;
    /*办公*/
    public static final int INNER_OFFICE = 2;
    /*系统*/
    public static final int SYSTEM = 3;
    /*当前选中的tab*/
    public int currentTab = PROJECT_MANAGENT;
    private DropDownPoupWindow popupWindow;
    /*标题栏四个按钮类型*/
    /*功能*/
    public static final int MODULE = 0;
    /*工程类型*/
    public static final int ENGINEERING = 1;
    /*反馈状态*/
    public static final int STATUS = 2;
    /*项目选择*/
    public static final int SELECT_PROJECT = 3;
    /*工程管理*/
    public static final int MODULE_ENGINEERING_MANAGEMENT = 0;
    /*轨迹*/
    public static final int MODULE_TRACK = 1;
    /*智能控制*/
    public static final int MODULE_INTELLIGENT = 2;
    /*业绩*/
    public static final int MODULE_YEJI = 3;
    /*供需*/
    public static final int MODULE_GONGXU = 3;
    /*标题栏 第一个按钮 当前选中的功能*/
    public int currentModuleType = MODULE_ENGINEERING_MANAGEMENT;
    private final String TAG = EngineeringMainForManagerActivity.class.getSimpleName();
    private AccountInfoBean accountInfoBean;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        // 沉浸式状态栏
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    // | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
            );
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    //  | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            // window.setNavigationBarColor(Color.TRANSPARENT);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        setContentView(R.layout.layout_engineeringmain_for_manager);

        init();
        // tv_title.setText(getResources().getText(R.string.engineering_management));
        tv_title.setText("");

    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        if (intent != null) {
            boolean isExit = intent.getBooleanExtra(ConstantUtil.KEY_1, false);
            if (isExit) {
                Intent mItent = new Intent(this, LoginActivity.class);
                startActivity(mItent);
                this.finish();
            }
        }
    }

    private void init() {
        rl_back = findViewById(R.id.rl_back);
        tv_title = findViewById(R.id.tv_title);
        ll_op_one = findViewById(R.id.ll_op_one);
        ll_op_two = findViewById(R.id.ll_op_two);
        ll_op_two = findViewById(R.id.ll_op_two);
        ll_op_three = findViewById(R.id.ll_op_three);
        ll_op_four = findViewById(R.id.ll_op_four);
        img_op_one = findViewById(R.id.img_op_one);
        img_op_two = findViewById(R.id.img_op_two);
        img_op_three = findViewById(R.id.img_op_three);
        img_op_four = findViewById(R.id.img_op_four);
        img_tri_one = findViewById(R.id.img_tri_one);
        img_tri_two = findViewById(R.id.img_tri_two);
        img_tri_three = findViewById(R.id.img_tri_three);
        img_tri_four = findViewById(R.id.img_tri_four);
        rl_head = findViewById(R.id.rl_head);
        tv_headtop = findViewById(R.id.tv_headtop);
        tv_headbottom = findViewById(R.id.tv_headbottom);
        iv_tab_manager = findViewById(R.id.img_engineering_manager);
        iv_tab_order = findViewById(R.id.main_engineering_order);
        iv_tab_office = findViewById(R.id.main_engineering_office);
        iv_tab_systems = findViewById(R.id.main_engineering_systems);
        textview_project_manager=findViewById(R.id.textview_project_manager);
        tv_project_order=findViewById(R.id.tv_project_order);
        textview_call=findViewById(R.id.textview_call);
        tv_project_systems=findViewById(R.id.tv_project_systems);
        ll_tab_bottom = findViewById(R.id.ll_tab_bottom);
        img_head = findViewById(R.id.img_head);

        layout_engineering_manager = findViewById(R.id.layout_engineering_manager);
        layout_engineering_order = findViewById(R.id.layout_engineering_order);
        layout_engineering_office = findViewById(R.id.layout_engineering_office);
        layout_engineering_systems = findViewById(R.id.layout_engineering_systems);
        viewpager = (CustomViewPager) findViewById(R.id.viewpager);
        viewpager.setScanScroll(false);
        indicator = findViewById(R.id.indicator);

        rl_head.setVisibility(View.VISIBLE);

        rl_back.setVisibility(View.GONE);
        img_head.setOnClickListener(this);
        layout_engineering_manager.setOnClickListener(this);
        layout_engineering_order.setOnClickListener(this);
        layout_engineering_office.setOnClickListener(this);
        layout_engineering_systems.setOnClickListener(this);
        ll_op_one.setOnClickListener(this);
        ll_op_two.setOnClickListener(this);
        ll_op_three.setOnClickListener(this);
        ll_op_four.setOnClickListener(this);

        accountInfoBean = MyApplicaton.getApplication().getAccountInfoBean();
        if (null != accountInfoBean) {
            if (accountInfoBean.getRoleCategory() == CommonEnum.ROLECATEGORY.MANAGER) {
                tv_headbottom.setText("工程管理/" + accountInfoBean.getAccountName());

                String companyName = accountInfoBean.getCompanyName();
                if (!TextUtils.isEmpty(companyName) && !"null".equals(companyName)) {
                    tv_headtop.setText(companyName);
                }
                Glide.with(this).load(accountInfoBean.getAvatar()).bitmapTransform(new GlideCircleTransform(this)).crossFade(1000).error(R.mipmap.default_avatar).into(img_head);
            }
        }

        mapForManagerFragment = new MapForManagerFragment();
        workSheetListFragment = new EngineeringOrderManagementForManageFragment();
        internalOffficeFragemnt = new InternalOfficeFragment();
        systemFragment = new SettingFragmet();

        listFragments = new ArrayList<Fragment>();
        listFragments.add(mapForManagerFragment);
        listFragments.add(workSheetListFragment);
        listFragments.add(internalOffficeFragemnt);
        listFragments.add(systemFragment);

        adapter = new ProjectMainViewPageAdapter(getSupportFragmentManager(), listFragments);
        viewpager.setAdapter(adapter);
        viewpager.setOffscreenPageLimit(4);

        indicator.setViewPager(viewpager);
        indicator.setFades(false);
        indicator.setSelectedColor(getResources().getColor(R.color.rgb_17a5ef));
        viewpager.setCurrentItem(PROJECT_MANAGENT);
        switchTab(PROJECT_MANAGENT);

        indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

            @Override
            public void onPageSelected(int position) {
                switchTab(position);
                currentTab = position;

            }

            @Override
            public void onPageScrolled(int arg0, float arg1, int arg2) {
            }

            @Override
            public void onPageScrollStateChanged(int arg0) {

            }
        });

        img_op_one.setBackgroundResource(R.mipmap.title_icon_menu);
        img_op_two.setBackgroundResource(R.mipmap.icon_hand);
        img_op_three.setBackgroundResource(R.mipmap.icon_produced);
        img_op_four.setBackgroundResource(R.mipmap.icon_patrol);


        ll_op_one.setVisibility(View.VISIBLE);
        ll_op_two.setVisibility(View.VISIBLE);
        ll_op_three.setVisibility(View.VISIBLE);
        ll_op_four.setVisibility(View.VISIBLE);

    }

    private void switchTab(int pos) {
        // TODO Auto-generated method stub
        switch (pos) {
            case PROJECT_MANAGENT:
                layout_engineering_manager.setSelected(true);
//                layout_engineering_manager.setBackgroundColor(getResources().getColor(R.color.rgb_17a5ef));
//                iv_tab_manager.setImageDrawable(getResources().getDrawable(R.mipmap.icon_engineering_management_pressed));
                iv_tab_manager.setImageDrawable(getResources().getDrawable(R.mipmap.tab_engineering_pressed));
                textview_project_manager.setTextColor(getResources().getColor(R.color.rgb_17a5ef));

                layout_engineering_order.setSelected(false);
//                layout_engineering_order.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_order.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_order));
                iv_tab_order.setImageDrawable(getResources().getDrawable(R.mipmap.tab_manage_normal));
                tv_project_order.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                layout_engineering_office.setSelected(false);
//                layout_engineering_office.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_office.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_office));
                iv_tab_office.setImageDrawable(getResources().getDrawable(R.mipmap.tab_office_normal));
                textview_call.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                layout_engineering_systems.setSelected(false);
//                layout_engineering_systems.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_systems.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_systems));
                iv_tab_systems.setImageDrawable(getResources().getDrawable(R.mipmap.tab_setting_normal));
                tv_project_systems.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                //  tv_title.setText(getResources().getText(R.string.engineering_management));
                tv_title.setText("");

                img_op_one.setBackgroundResource(R.mipmap.title_icon_menu);
                img_op_two.setBackgroundResource(R.mipmap.icon_hand);
                img_op_three.setBackgroundResource(R.mipmap.icon_produced);
                img_op_four.setBackgroundResource(R.mipmap.icon_patrol);


                ll_op_one.setVisibility(View.VISIBLE);
                ll_op_two.setVisibility(View.VISIBLE);
                ll_op_three.setVisibility(View.VISIBLE);
                ll_op_four.setVisibility(View.VISIBLE);

                rl_head.setVisibility(View.VISIBLE);
                rl_back.setVisibility(View.GONE);
                break;
            case WORK_SHEETS_LIST:
                layout_engineering_manager.setSelected(false);
//                layout_engineering_manager.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_manager.setImageDrawable(getResources().getDrawable(R.mipmap.icon_engineering_management));
                iv_tab_manager.setImageDrawable(getResources().getDrawable(R.mipmap.tab_engineering_normal));
                textview_project_manager.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                layout_engineering_order.setSelected(true);
//                layout_engineering_order.setBackgroundColor(getResources().getColor(R.color.rgb_17a5ef));
//                iv_tab_order.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_order_pressed));
                iv_tab_order.setImageDrawable(getResources().getDrawable(R.mipmap.tab_manage_pressed));
                tv_project_order.setTextColor(getResources().getColor(R.color.rgb_17a5ef));

                layout_engineering_office.setSelected(false);
//                layout_engineering_office.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_office.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_office));
                iv_tab_office.setImageDrawable(getResources().getDrawable(R.mipmap.tab_office_normal));
                textview_call.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                layout_engineering_systems.setSelected(false);
//                layout_engineering_systems.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_systems.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_systems));
                iv_tab_systems.setImageDrawable(getResources().getDrawable(R.mipmap.tab_setting_normal));
                tv_project_systems.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                // tv_title.setText(getResources().getText(R.string.work_order_management));
                tv_title.setText("");

                ll_op_one.setVisibility(View.GONE);
                ll_op_two.setVisibility(View.GONE);
                ll_op_three.setVisibility(View.GONE);
                ll_op_four.setVisibility(View.GONE);

                rl_head.setVisibility(View.VISIBLE);
                rl_back.setVisibility(View.GONE);

                break;
            case INNER_OFFICE:
                layout_engineering_manager.setSelected(false);
//                layout_engineering_manager.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_manager.setImageDrawable(getResources().getDrawable(R.mipmap.icon_engineering_management));
                iv_tab_manager.setImageDrawable(getResources().getDrawable(R.mipmap.tab_engineering_normal));
                textview_project_manager.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                layout_engineering_order.setSelected(false);
//                layout_engineering_order.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_order.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_order));
                iv_tab_order.setImageDrawable(getResources().getDrawable(R.mipmap.tab_manage_normal));
                tv_project_order.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                layout_engineering_office.setSelected(true);
//                layout_engineering_office.setBackgroundColor(getResources().getColor(R.color.rgb_17a5ef));
//                iv_tab_office.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_office_pressed));
                iv_tab_office.setImageDrawable(getResources().getDrawable(R.mipmap.tab_office_pressed));
                textview_call.setTextColor(getResources().getColor(R.color.rgb_17a5ef));

                layout_engineering_systems.setSelected(false);
//                layout_engineering_systems.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_systems.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_systems));
                iv_tab_systems.setImageDrawable(getResources().getDrawable(R.mipmap.tab_setting_normal));
                tv_project_systems.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                // tv_title.setText(getResources().getText(R.string.inner_office));
                tv_title.setText("");

                ll_op_one.setVisibility(View.GONE);
                ll_op_two.setVisibility(View.GONE);
                ll_op_three.setVisibility(View.GONE);
                ll_op_four.setVisibility(View.GONE);

                rl_head.setVisibility(View.VISIBLE);
                rl_back.setVisibility(View.GONE);

                break;
            case SYSTEM:
                layout_engineering_manager.setSelected(false);
//                layout_engineering_manager.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_manager.setImageDrawable(getResources().getDrawable(R.mipmap.icon_engineering_management));
                iv_tab_manager.setImageDrawable(getResources().getDrawable(R.mipmap.tab_engineering_normal));
                textview_project_manager.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                layout_engineering_order.setSelected(false);
//                layout_engineering_order.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_order.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_order));
                iv_tab_order.setImageDrawable(getResources().getDrawable(R.mipmap.tab_manage_normal));
                tv_project_order.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                layout_engineering_office.setSelected(false);
//                layout_engineering_office.setBackgroundColor(getResources().getColor(R.color.color_f7f7f7));
//                iv_tab_office.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_office));
                iv_tab_office.setImageDrawable(getResources().getDrawable(R.mipmap.tab_office_normal));
                textview_call.setTextColor(getResources().getColor(R.color.color_a2a2a4));

                layout_engineering_systems.setSelected(true);
//                layout_engineering_systems.setBackgroundColor(getResources().getColor(R.color.rgb_17a5ef));
//                iv_tab_systems.setImageDrawable(getResources().getDrawable(R.mipmap.tab_project_systems_pressed));
                iv_tab_systems.setImageDrawable(getResources().getDrawable(R.mipmap.tab_setting_pressed));
                tv_project_systems.setTextColor(getResources().getColor(R.color.rgb_17a5ef));

                // tv_title.setText(getResources().getText(R.string.system));
                tv_title.setText("");

                ll_op_one.setVisibility(View.GONE);
                ll_op_two.setVisibility(View.GONE);
                ll_op_three.setVisibility(View.GONE);
                ll_op_four.setVisibility(View.GONE);

                rl_head.setVisibility(View.VISIBLE);
                rl_back.setVisibility(View.GONE);

                break;

        }

    }

    /**
     * 功能1
     *
     * @param anchor
     */
    private void showModulePopupWindow(View anchor) {
        if (null != popupWindow)
            popupWindow.dismiss();

        popupWindow = new DropDownPoupWindow(this, TAG, MODULE, R.layout.popwindow_map_for_manager_module, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        //  backgroundAlpha(0.6f);
        img_tri_one.setVisibility(View.VISIBLE);

        popupWindow.setOnClickListener(this);
        popupWindow.setCusOnDismissListener(new PopupWindow.OnDismissListener() {

            @Override
            public void onDismiss() {
                backgroundAlpha(1f);
                img_tri_one.setVisibility(View.GONE);
            }
        });
        popupWindow.showPopupWindow(anchor, anchor.getLayoutParams().width / 2, 5);
    }

    /**
     * 功能2
     *
     * @param anchor
     */
    private void showEngineeringPopupWindwo(View anchor) {
        if (null != popupWindow)
            popupWindow.dismiss();

        popupWindow = new DropDownPoupWindow(this, TAG, ENGINEERING, R.layout.popwindow_map_for_manager_engineering, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        // backgroundAlpha(0.6f);
        img_tri_two.setVisibility(View.VISIBLE);
        popupWindow.setOnClickListener(this);
        popupWindow.setCusOnDismissListener(new PopupWindow.OnDismissListener() {

            @Override
            public void onDismiss() {
                backgroundAlpha(1f);
                img_tri_two.setVisibility(View.GONE);
            }
        });
        popupWindow.showPopupWindow(anchor, anchor.getLayoutParams().width / 2, 5);
    }

    /**
     * 功能3
     *
     * @param anchor
     */
    private void showStatusPopupWindow(View anchor) {
        if (null != popupWindow)
            popupWindow.dismiss();

        popupWindow = new DropDownPoupWindow(this, TAG, STATUS, R.layout.popwindow_map_for_manager_status, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        // backgroundAlpha(0.6f);
        img_tri_three.setVisibility(View.VISIBLE);
        popupWindow.setOnClickListener(this);
        popupWindow.setCusOnDismissListener(new PopupWindow.OnDismissListener() {

            @Override
            public void onDismiss() {
                backgroundAlpha(1f);
                img_tri_three.setVisibility(View.GONE);
            }
        });
        popupWindow.showPopupWindow(anchor, anchor.getLayoutParams().width / 2, 5);
    }


    /**
     * 功能4
     *
     * @param anchor
     */
    private void showSelectPopupWindwo(View anchor) {
        if (null != popupWindow)
            popupWindow.dismiss();

        popupWindow = new DropDownPoupWindow(this, TAG, SELECT_PROJECT, R.layout.popwindow_map_for_manager_selectproject, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        // backgroundAlpha(0.6f);
        img_tri_four.setVisibility(View.VISIBLE);
        popupWindow.setOnClickListener(this);
        popupWindow.setCusOnDismissListener(new PopupWindow.OnDismissListener() {

            @Override
            public void onDismiss() {
                backgroundAlpha(1f);
                img_tri_four.setVisibility(View.GONE);
            }
        });
        popupWindow.showPopupWindow(anchor, anchor.getLayoutParams().width / 2, 5);
    }


    /**
     * 设置添加屏幕的背景透明度
     *
     * @param bgAlpha
     */
    private void backgroundAlpha(float bgAlpha) {
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.alpha = bgAlpha;
        getWindow().setAttributes(lp);
    }

    @Override
    public void onClick(View view) {
        Intent mIntent;
        switch (view.getId()) {
            // 头像
            case R.id.img_head:
                Intent intent = new Intent(EngineeringMainForManagerActivity.this, AvatarImageShowerActivity.class);
                intent.putExtra("imageUrl", accountInfoBean.getAvatar());
                startActivity(intent);
                break;
            case R.id.ll_op_one:
                showModulePopupWindow(view);
                break;
            case R.id.ll_op_two:
                showEngineeringPopupWindwo(view);
                break;
            case R.id.ll_op_three:
                showStatusPopupWindow(view);
                break;
            case R.id.ll_op_four:
                showSelectPopupWindwo(view);
                break;

            // 工程安装
            case R.id.ll_engineering_installation:
                mIntent = new Intent(EngineeringMainForManagerActivity.this, EngineeringInstallStatusTableForManagerActivity1.class);
                startActivity(mIntent);
                break;
            // 工程施工
            case R.id.ll_engineering_construct:
                mIntent = new Intent(EngineeringMainForManagerActivity.this, ProductionScheduleActivity.class);
                startActivity(mIntent);
                break;
            // 批量安装
            case R.id.ll_batch_engineering:
                mIntent = new Intent(EngineeringMainForManagerActivity.this, EngineeringInstallationScheduleTableActivity.class);
                startActivity(mIntent);
                break;
            // 上刊
            case R.id.ll_publication:
                mIntent = new Intent(EngineeringMainForManagerActivity.this, PublicationStatusTableForManagerActivity2.class);
                startActivity(mIntent);
                break;
            // 维修
            case R.id.ll_maintenance:
                mIntent = new Intent(EngineeringMainForManagerActivity.this, ProductStatusTableActivity.class);
                startActivity(mIntent);
                break;
            // 勘察
            case R.id.ll_patrol:
                mIntent = new Intent(EngineeringMainForManagerActivity.this, PatrolStatusTableForManagerActivity.class);
                startActivity(mIntent);
                break;

            // 工程管理
            case R.id.ll_engineering_management:
                currentModuleType = MODULE_ENGINEERING_MANAGEMENT;
                mapForManagerFragment.getOrderList(currentModuleType);
                break;
            // 轨迹
            case R.id.ll_track:
                break;
            // 智能控制
            case R.id.ll_intelligent_control:
                break;
            // 业绩
            case R.id.ll_achievement:
                currentModuleType = MODULE_YEJI;
                mapForManagerFragment.getOrderList(currentModuleType);
                break;
            // 供需中心
            case R.id.ll_gongxu:
                break;
            case R.id.layout_engineering_manager:
                if (currentTab != PROJECT_MANAGENT) {

                    currentTab = PROJECT_MANAGENT;
                    viewpager.setCurrentItem(PROJECT_MANAGENT);
                    switchTab(PROJECT_MANAGENT);
                }

                break;
            case R.id.layout_engineering_order:
                if (currentTab != WORK_SHEETS_LIST) {
                    currentTab = WORK_SHEETS_LIST;

                    viewpager.setCurrentItem(WORK_SHEETS_LIST);
                    switchTab(WORK_SHEETS_LIST);
                }
                break;
            case R.id.layout_engineering_office:
                if (currentTab != INNER_OFFICE) {
                    currentTab = INNER_OFFICE;

                    viewpager.setCurrentItem(INNER_OFFICE);
                    switchTab(INNER_OFFICE);
                }

                break;
            case R.id.layout_engineering_systems:
                if (currentTab != SYSTEM) {
                    currentTab = SYSTEM;

                    viewpager.setCurrentItem(SYSTEM);
                    switchTab(SYSTEM);
                }
                break;
        }

    }

}
